
export const getTableColumns = ({ params }) => [
	{
		title: "用户名",
		dataIndex: "username",
		width: 140,
		ellipsis: true
	},
	{
		title: "部门",
		dataIndex: "orgName",
		width: 140,
		ellipsis: true
	},
	{
		title: "手机号",
		dataIndex: "phone",
		width: 140,
		ellipsis: true
	},
	{
		title: "邮箱",
		dataIndex: "email",
		width: 140,
		ellipsis: true
	},
	{
		title: "登录账号",
		dataIndex: "username",
		width: 100,
		ellipsis: true,
	},
	// {
	// 	title: "登录密码",
	// 	dataIndex: "password",
	// 	width: 100,
	// 	ellipsis: true,
	// },
	{
		title: "性别",
		dataIndex: "sex",
		width: 100,
		ellipsis: true,
		render: (_: any, record: any) => {
			return (
				<span>
					{record.sex ? record.sex === '1' ? '男' : '女' : '-'}
				</span>
			)
		}
	},
	{
		title: "角色",
		dataIndex: "roleName",
		width: 140,
		ellipsis: true
	},
	{
		title: "用户状态",
		dataIndex: "status",
		width: 100,
		ellipsis: true,
		render: (_: any, record: any) => {
			return (
				<span style={{}}>
					{USER_USE_STATUS.find(item => `${item.value}` === `${record.status}`)?.label}
				</span>
			)
		}
	},
	{
		title: "创建日期",
		dataIndex: "createTime",
		width: 140,
		ellipsis: true
	},
];

export const USER_STATUS = [
	{ label: '在线', value: 1 },
	{ label: '离线', value: 2 }
]

export const GENDER_LIST = [
	{ label: '男', value: '1' },
	{ label: '女', value: '0' }
]

export const USER_USE_STATUS = [
	{ label: '禁用', value: 0 },
	{ label: '启用', value: 1 }
]

export const getSearchColumns = ({orgList, roleList}: any) => [
	{
		type: "input",
		placeholder: "用户名",
		name: "nickname"
	},
	{
		type: "select",
		placeholder: "所属组织",
		name: "orgId",
		options: orgList?.data || [],
		fieldProps:{
			fieldNames: {
				label: 'name',  // 显示文本对应的字段
				value: 'id',    // 值对应的字段
			}
		}
	},
	{
		type: "select",
		placeholder: "角色",
		name: "roleId",
		options: roleList?.data || [],
		fieldProps:{
			fieldNames: {
				label: 'name',  // 显示文本对应的字段
				value: 'id',    // 值对应的字段
			}
		}
	},
	{
		type: "select",
		placeholder: "用户状态",
		name: "status",
		options: USER_USE_STATUS
	},
]

export const getCreateColumns = ({orgList, roleList, defaultValues}: any) => {
	return [
		{
			type: "input",
			placeholder: "用户名",
			label: "用户名",
			name: "username",
			rules: [{ required: true, message: '这是必填项' }]
		},
		{
			type: "input",
			placeholder: "用户昵称",
			label: "用户昵称",
			name: "nickname",
			rules: [
				{ required: true, message: '这是必填项' },
			]
		},
		{
			type: "password",
			placeholder: "密码",
			label: "密码",
			name: "password",
			rules: [
				{ required: true, message: '这是必填项' },
			],
			fieldProps: {
				disabled: !!defaultValues && defaultValues.id
			}
		},
		{
			type: "input",
			placeholder: "邮箱",
			label: "邮箱",
			name: "email",
			rules: [
				{ required: true, message: '这是必填项' },
				{ type: 'email', message: '请输入有效的邮箱地址' }
			],
			fieldProps: {
				disabled: !!defaultValues && defaultValues.id
			}
		},
		{
			type: "input",
			placeholder: "手机号",
			label: "手机号",
			name: "phone",
			rules: [
				{ required: true, message: '这是必填项' },
				{ pattern: /^1[3-9]\d{9}$/, message: '请输入正确的手机号码' }
			],
			fieldProps: {
				disabled: !!defaultValues && defaultValues.id
			}
		},
		{
			type: "select",
			placeholder: "角色",
			label: "角色",
			name: "roleId",
			options: roleList?.data || [],
			fieldProps: {
				fieldNames: {
					label: 'name',  // 显示文本对应的字段
					value: 'id',    // 值对应的字段
				}
			},
			rules: [
				{ required: true, message: '这是必填项' },
			]
		},
		{
			type: "select",
			placeholder: "所属部门",
			label: "所属部门",
			name: "orgId",
			options: orgList?.data || [],
			fieldProps: {
				fieldNames: {
					label: 'name',  // 显示文本对应的字段
					value: 'id',    // 值对应的字段
				}
			}
		},
		{
			type: "radioGroup",
			placeholder: "性别",
			label: "性别",
			name: "sex",
			options: GENDER_LIST,
			rules: [
				{ required: true, message: '这是必填项' },
			]
		},
		{
			type: "radioGroup",
			placeholder: "用户状态",
			label: "用户状态",
			name: "status",
			options: USER_USE_STATUS,
			rules: [
				{ required: true, message: '这是必填项' },
			]
		}
	]
}